-
Notifications
You must be signed in to change notification settings - Fork 561
Properly type purchaseData as Record<string, unknown> #7508
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Properly type purchaseData as Record<string, unknown> #7508
Conversation
🦋 Changeset detectedLatest commit: 81647bb The changes in this PR will be included in the next version bump. This PR includes changesets to release 3 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
## Walkthrough
The changes update the typing of the `purchaseData` property from generic `object` or `unknown` types to a specific `PurchaseData` type (defined as `Record<string, unknown>`) across multiple packages and modules. Redundant type assertions for `purchaseData` were removed in UI components. A changeset documents the patch-level update for the "thirdweb" package reflecting these typing improvements.
## Changes
| File(s) | Change Summary |
|---------------------------------------------------------------------------------------------------------|--------------------------------------------------------------------------------------------------------------------------|
| .changeset/orange-files-admire.md | Added a changeset file describing a patch update for improved typing of `purchaseData`. |
| packages/thirdweb/src/pay/types.ts | Added new type alias `PurchaseData = Record<string, unknown>`. |
| packages/thirdweb/src/react/core/hooks/connection/ConnectButtonProps.ts | Changed `PayUIOptions.purchaseData` type from `object` to `PurchaseData`. |
| packages/thirdweb/src/react/core/hooks/transaction/useSendTransaction.ts | Changed `SendTransactionPayModalConfig.purchaseData` type from `object` to `PurchaseData`. |
| packages/thirdweb/src/react/web/ui/PayEmbed.tsx | Removed explicit type assertions casting `purchaseData` when passing to `BuyWidget`, `CheckoutWidget`, and `TransactionWidget`. |
| packages/thirdweb/src/bridge/Buy.ts | Changed `purchaseData` type in `prepare.Options` and `prepare.Result.intent` from `unknown` to `PurchaseData`. |
| packages/thirdweb/src/bridge/Onramp.ts | Changed `purchaseData` type in `OnrampIntent`, `OnrampApiRequestBody`, and `prepare.Options` from `unknown` to `PurchaseData`. |
| packages/thirdweb/src/bridge/OnrampStatus.ts | Changed `purchaseData` type in `status.Result` union variants from `unknown` to `PurchaseData`. |
| packages/thirdweb/src/bridge/Sell.ts | Changed `purchaseData` type in `prepare.Options` and `prepare.Result.intent` from `unknown` to `PurchaseData`. |
| packages/thirdweb/src/bridge/Transfer.ts | Changed `purchaseData` type in `prepare.Options` and `prepare.Result["intent"]` from `unknown` to `PurchaseData`. |
| packages/thirdweb/src/bridge/types/Status.ts | Changed `purchaseData` type in `Status` union variants from `unknown` to `PurchaseData`. |
| packages/thirdweb/src/pay/buyWithCrypto/getQuote.ts | Changed `GetBuyWithCryptoQuoteParams.purchaseData` type from `object` to `PurchaseData`. |
| packages/thirdweb/src/pay/buyWithCrypto/getStatus.ts | Changed `BuyWithCryptoStatus.purchaseData` type from `object` to `PurchaseData`; updated related function parameter types. |
| packages/thirdweb/src/pay/buyWithCrypto/getTransfer.ts | Changed `GetBuyWithCryptoTransferParams.purchaseData` type from `object` to `PurchaseData`. |
| packages/thirdweb/src/pay/buyWithFiat/getQuote.ts | Changed `GetBuyWithFiatQuoteParams.purchaseData` type from `object` to `PurchaseData`. |
| packages/thirdweb/src/pay/buyWithFiat/getStatus.ts | Changed `BuyWithFiatStatus.purchaseData` type from `object` to `PurchaseData`; updated related function parameter types. |
| packages/thirdweb/src/react/web/ui/Bridge/BuyWidget.tsx | Changed `BuyWidgetProps.purchaseData` type from `Record<string, unknown>` to `PurchaseData`. |
| packages/thirdweb/src/react/web/ui/Bridge/CheckoutWidget.tsx | Changed `CheckoutWidgetProps.purchaseData` type from `Record<string, unknown>` to `PurchaseData`. |
| packages/thirdweb/src/react/web/ui/Bridge/QuoteLoader.tsx | Changed `QuoteLoaderProps.purchaseData` and `getBridgeParams` parameter type from `object` to `PurchaseData`. |
| packages/thirdweb/src/react/web/ui/Bridge/TransactionWidget.tsx | Changed `TransactionWidgetProps.purchaseData` type from `Record<string, unknown>` to `PurchaseData`. |
| packages/thirdweb/src/react/web/ui/Bridge/BridgeOrchestrator.tsx | Changed `BridgeOrchestratorProps.purchaseData` from required `object | undefined` to optional `PurchaseData`. |
## Possibly related PRs
- thirdweb-dev/js#7507: Refined `purchaseData` typing and previously introduced passing `purchaseData` as a prop to payment components.
- thirdweb-dev/js#7202: Addresses `purchaseData` handling in `getBuyWithCryptoTransfer`, related to transfer process and type safety.
- thirdweb-dev/js#7354: Introduced new payment-related widgets whose props include `purchaseData`; this PR updates their typings.
## Suggested reviewers
- 0xFirekeeper 📜 Recent review detailsConfiguration used: CodeRabbit UI 📒 Files selected for processing (21)
✅ Files skipped from review due to trivial changes (2)
🚧 Files skipped from review as they are similar to previous changes (19)
⏰ Context from checks skipped due to timeout of 90000ms (8)
✨ Finishing Touches
🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
How to use the Graphite Merge QueueAdd either label to this PR to merge it via the merge queue:
You must have a Graphite account in order to use the merge queue. Sign up using this link. An organization admin has enabled the Graphite Merge Queue in this repository. Please do not merge from GitHub as this will restart CI on PRs being processed by the merge queue. This stack of pull requests is managed by Graphite. Learn more about stacking. |
size-limit report 📦
|
c2596fe
to
610f4f4
Compare
610f4f4
to
81647bb
Compare
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #7508 +/- ##
=======================================
Coverage 51.96% 51.96%
=======================================
Files 952 952
Lines 64227 64224 -3
Branches 4238 4241 +3
=======================================
Hits 33377 33377
+ Misses 30743 30740 -3
Partials 107 107
🚀 New features to boost your workflow:
|
Properly Type
purchaseData
ParameterThis PR improves type safety by changing the type of
purchaseData
fromobject
toRecord<string, unknown>
in multiple locations:Additionally, it removes unnecessary type casting in PayEmbed.tsx where
purchaseData
was being cast toRecord<string, unknown>
.A changeset has been added to document this patch-level change.
Summary by CodeRabbit
PR-Codex overview
This PR focuses on improving type safety by replacing instances of
Record<string, unknown>
andobject
with the new typePurchaseData
across various files.Detailed summary
PurchaseData
type intypes.ts
.purchaseData?: Record<string, unknown>
withpurchaseData?: PurchaseData
in multiple components and types.PurchaseData
.